package com.xlh.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;

import com.xlh.adapter.GridViewAndListViewAdapter;

public class MyListView extends ListView {

	public GridViewAndListViewAdapter getDataAdapter() {
		return dataAdapter;
	}

	public void setDataAdapter(GridViewAndListViewAdapter dataAdapter) {

		this.dataAdapter = dataAdapter;

		this.setAdapter(this.dataAdapter);
	}

	private GridViewAndListViewAdapter dataAdapter;

	public int getMode() {
		return mode;
	}

	public void setMode(int mode) {
		this.mode = mode;
	}

	private int mode=1;


	public MyListView(Context context,int mode) {
		this(context,null);
		this.mode=mode;
		// TODO Auto-generated constructor stub
	}

	public MyListView(Context context, AttributeSet attrs) {
		this(context,attrs,0);
		// TODO Auto-generated constructor stub
	}

	public MyListView(Context context, AttributeSet attrs, int defStyleAttr) {
			super(context, attrs, defStyleAttr);
			// TODO Auto-generated constructor stub
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
		if(this.mode==1){
			int expandMeasure = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,MeasureSpec.AT_MOST);
			super.onMeasure(widthMeasureSpec,expandMeasure);
		}else{
			super.onMeasure(widthMeasureSpec,heightMeasureSpec);
		}

	}



}
